# 列表倒序
from time import sleep

li = [1, 2, 3, 4]
# print(reversed(li).__next__())
# for item in reversed(li):
#     print(item)
li_rev = list(reversed(li))
print(li)
print(li_rev)
# string reverse
a = 'abcdefghihklmn'
print(a[::-1])

# generate a iterator
class MyNumbers:
    def __iter__(self):
        self.a = 1
        return self
    def __next__(self):
        x = self.a
        self.a += 1
        return x

mn = MyNumbers()
# iter() next()
myiter = iter(mn)
print(next(iter(myiter)))
# print(next(myiter))
# print(next(myiter))
# print(next(myiter))
r = range(3)
r_iter = iter(r)
while True:
    print(next(r_iter))
    sleep(1)

